
import { defineComponent } from 'vue';
import { getListQualificationManagement } from '@src/api/UserCenterApi'
export default defineComponent({
  name:'QualificationManagementFilter',
  props:{
    value:{
      type:Array,
      default:()=>[]
    },
    needLabel:{
      type:Boolean,
      default:true
    },
    label:{
      type:String,
      default:''
    }
  },
  setup(props, {emit}) {
    function toGetListQualificationManagement(params){
      return getListQualificationManagement(params).then(res=>{
        if(res.status === 0 ){
          return {
            ...res.data,
            list:res.data.list.map(item=>{
              return {
                label:item.qualificationName,
                value:item.id
              }
            })
          }
        }
      })
    }
    return {
      toGetListQualificationManagement
    }
  },
  render(h){
    return (
      <div>
        {this.needLabel && <label class="mar-b-8">{ this.label ? this.label : `${this.$t('common.label.subCertifications')}:`}</label>}
        <biz-remote-select value={this.value} remote-method={this.toGetListQualificationManagement} cleared={true} multiple={true} collapsed={true} collapseTags={true} placeholder={this.label ? this.$t('common.placeholder.select') : this.$t('common.label.subCertifications')} onInput={(e)=>this.$emit('input', e)}
        noDataText={this.$t('qualificationManagement.view.tips3')}
        />
      </div>
    )
  }
})